package cn.team11.smarteye.activity.callback;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import cn.team11.smarteye.utils.ToastUtil;

/**
 * Created by Yang on 2017/11/18.
 * 用来判断前台、后台运行
 */

public class CateyeActivityCallback implements Application.ActivityLifecycleCallbacks{

    private int count = 0;

    public CateyeActivityCallback() {
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle bundle) {

    }

    @Override
    public void onActivityStarted(Activity activity) {
        if (count == 0){
            //ToastUtil.showToast("切换到前台");
        }

        count++;
    }

    @Override
    public void onActivityResumed(Activity activity) {

    }

    @Override
    public void onActivityPaused(Activity activity) {

    }

    @Override
    public void onActivityStopped(Activity activity) {
        count--;
        if (count == 0){
            //切换到后台
            //ToastUtil.showToast("切换到后台");
        }
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {

    }

    @Override
    public void onActivityDestroyed(Activity activity) {

    }
}
